import pymysql
from fastapi import FastAPI,HTTPException,Form
#初始化
app=FastAPI()
db={
    "host":"127.0.0.1",
    "user":"root",
    "password":"123456",
    "database":"2304a",
    "charset":"utf8"
}
#接口
@app.post('/qwe')
#方法
def jinru(
    eid:str=Form(...),
    ename:str=Form(...),
    eposition:str=Form(...),
    ephone:str=Form(...),
):
    #链接数据库
    con=pymysql.connect(**db)
    #设置游标
    cursor=con.cursor()
    cursor.execute("insert into employee(eid,ename,eposition,ephone) values (%s,%s,%s,%s)",(eid,ename,eposition,ephone))
    con.commit()
    return{"msg":"注册成功"}